{% extends "ErpBundle::layout.html.twig" %}
{% block title %}{{ parent() }} - New Event{% endblock %}
{% block body %}
Creer un Sondage
<form method="post" id="pollForm"><br >
<a class="addElement" href="#" ><img class="accueil" src="{{ asset('bundles/erp/images/button-2794.png') }}"></a>
<a class="deleteElement" href="#" ><img class="accueil" src="{{ asset('bundles/erp/images/button-3363.png') }}"></a><br><br>
<table class="tableEvent">
	<tr>
		<td class="tdPoll1">
	   	 <label for="nom">Su<strong>jet</strong>:</label>
	    </td>
	    <td class="tdEvent2">
	    <input type="text" id="subject" name="_subject" />
		</td>
	</tr><tr></tr>
	<tr>
		<td class="tdPoll1">
	    <label for="choix1">Choix<strong> 1</strong>:</label>
	    </td>
	    <td class="tdPoll2">
	    <input type="text" id="choix1" name="_choix1" />
		</td>
	</tr>
	<tr>
		<td class="tdPoll1">
	    <label for="choix2">Choix<strong> 2</strong>:</label>
	    </td>
	    <td class="tdPoll2">
	    <input type="text" id="choix2" name="_choix2" />
		</td>
	</tr>
	<tr class="addblock">
	
	</tr>
	<tr>
	<td></td>
	   <td class="tdEvent1">
   		<button type="submit" class="buttonPoll"><img src="{{ asset('bundles/erp/images/valider.png') }}"/></button>
   		</td>
   	</tr>
</table>
</form>
<a href="{{ asset('app_dev.php/erp/afficher_sondage') }}">Retour</a>

<script>

    var i = 3;
    
	$(".addElement").click(function(){
			if(i < 11 )
			{
				var str = "<tr>";
				str += "<td class=\"tdPoll1\">";
				str += "<label for=\"choix"+i+"\">Choix<strong> "+ i +"</strong>:</label>";
				str += "</td>";
				str += "<td class=\"tdPoll2\">";
				str += "<input type=\"text\" id=\"choix"+i+"\" name=\"_choix"+i+"\" class=\"required\" />";
				str += "</td>";
				str += "</tr>";
				str += "<tr class=\"addblock\">";
				str += "</tr>";
				
				$(".addblock").replaceWith(str);
					i++;
				return false;
			}
		});

	$(".deleteElement").click(function(){	
		if(i >= 4 )
		{
			i = i-1;
			$("#choix"+i+"").parent().parent().remove();
			return false;
		}
	});

	$(document).ready(function(){
  		 $("#pollForm").validate({
  			 rules: {
  				 _subject: {
     	   		  required: true
     	   		    },
  	   		    _choix1: {
  	   		      required: true
  	   		    },
  	   		    _choix2: {
  	   		      required: true
  	   		    }
  			 }
  		 });
 	});
</script>

{% endblock %}